from urllib import error,request

try:
    res=request.urlopen("https://jianshu.com")
except error.HTTPError as e:
    print(e.code)
    print("-----------------")
    print(e.reason)
    print("-----------------")
    print(e.headers)